-- Copyright (c) Huawei Technologies Co., Ltd. 2025. All rights reserved.
--
-- this file licensed under the Mulan PSL v2.
-- You can use this software according to the terms and conditions of the Mulan PSL v2.
-- You may obtain a copy of Mulan PSL v2 at: http://license.coscl.org.cn/MulanPSL2
--
-- THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR
-- IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR
-- PURPOSE.
-- See the Mulan PSL v2 for more details.
--
-- Author: auto generate
-- Create: 2025-10-19
-- Description: DO NOT EDIT; Code generated by "message.lua.mako"
local validate = require 'mc.validate'
local utils = require 'mc.utils'
local mdb = require 'mc.mdb'

local CAN = {}

---@class CAN.PrintMetricsReq
---@field Channel integer
local TPrintMetricsReq = {}
TPrintMetricsReq.__index = TPrintMetricsReq
TPrintMetricsReq.group = {}

local function TPrintMetricsReq_from_obj(obj)
    return setmetatable(obj, TPrintMetricsReq)
end

function TPrintMetricsReq.new(Channel)
    return TPrintMetricsReq_from_obj({Channel = Channel or 255})
end
---@param obj CAN.PrintMetricsReq
function TPrintMetricsReq:init_from_obj(obj)
    self.Channel = obj.Channel or 255
end

function TPrintMetricsReq:remove_error_props(errs, obj)
    utils.remove_obj_error_property(obj, errs, TPrintMetricsReq.group)
end

TPrintMetricsReq.from_obj = TPrintMetricsReq_from_obj

TPrintMetricsReq.proto_property = {'Channel'}

TPrintMetricsReq.default = {0}

TPrintMetricsReq.descriptions = {[=[The channel number of canbus.]=]}

TPrintMetricsReq.struct = {{name = 'Channel', is_array = false, struct = nil}}

function TPrintMetricsReq:validate(prefix, errs, need_convert)
    prefix = prefix or ''

    validate.Optional(prefix .. 'Channel', self.Channel, 'uint8', false, errs, need_convert)

    TPrintMetricsReq:remove_error_props(errs, self)
    validate.CheckUnknowProperty(self, TPrintMetricsReq.proto_property, errs, need_convert)
    return self
end

function TPrintMetricsReq:unpack(_)
    return self.Channel
end

CAN.PrintMetricsReq = TPrintMetricsReq

---@class CAN.SendTestBoardcastRsp
local TSendTestBoardcastRsp = {}
TSendTestBoardcastRsp.__index = TSendTestBoardcastRsp
TSendTestBoardcastRsp.group = {}

local function TSendTestBoardcastRsp_from_obj(obj)
    return setmetatable(obj, TSendTestBoardcastRsp)
end

function TSendTestBoardcastRsp.new()
    return TSendTestBoardcastRsp_from_obj({})
end
---@param obj CAN.SendTestBoardcastRsp
function TSendTestBoardcastRsp:init_from_obj(obj)

end

function TSendTestBoardcastRsp:remove_error_props(errs, obj)
    utils.remove_obj_error_property(obj, errs, TSendTestBoardcastRsp.group)
end

TSendTestBoardcastRsp.from_obj = TSendTestBoardcastRsp_from_obj

TSendTestBoardcastRsp.proto_property = {}

TSendTestBoardcastRsp.default = {}

TSendTestBoardcastRsp.struct = {}

function TSendTestBoardcastRsp:validate(prefix, errs, need_convert)
    prefix = prefix or ''

    TSendTestBoardcastRsp:remove_error_props(errs, self)
    validate.CheckUnknowProperty(self, TSendTestBoardcastRsp.proto_property, errs, need_convert)
    return self
end

function TSendTestBoardcastRsp:unpack(_)
end

CAN.SendTestBoardcastRsp = TSendTestBoardcastRsp

---@class CAN.SendTestBoardcastReq
---@field Channel integer
local TSendTestBoardcastReq = {}
TSendTestBoardcastReq.__index = TSendTestBoardcastReq
TSendTestBoardcastReq.group = {}

local function TSendTestBoardcastReq_from_obj(obj)
    return setmetatable(obj, TSendTestBoardcastReq)
end

function TSendTestBoardcastReq.new(Channel)
    return TSendTestBoardcastReq_from_obj({Channel = Channel})
end
---@param obj CAN.SendTestBoardcastReq
function TSendTestBoardcastReq:init_from_obj(obj)
    self.Channel = obj.Channel
end

function TSendTestBoardcastReq:remove_error_props(errs, obj)
    utils.remove_obj_error_property(obj, errs, TSendTestBoardcastReq.group)
end

TSendTestBoardcastReq.from_obj = TSendTestBoardcastReq_from_obj

TSendTestBoardcastReq.proto_property = {'Channel'}

TSendTestBoardcastReq.default = {0}

TSendTestBoardcastReq.descriptions = {[=[The channel number of testing canbus.]=]}

TSendTestBoardcastReq.struct = {{name = 'Channel', is_array = false, struct = nil}}

function TSendTestBoardcastReq:validate(prefix, errs, need_convert)
    prefix = prefix or ''

    validate.Optional(prefix .. 'Channel', self.Channel, 'uint8', false, errs, need_convert)

    TSendTestBoardcastReq:remove_error_props(errs, self)
    validate.CheckUnknowProperty(self, TSendTestBoardcastReq.proto_property, errs, need_convert)
    return self
end

function TSendTestBoardcastReq:unpack(_)
    return self.Channel
end

CAN.SendTestBoardcastReq = TSendTestBoardcastReq

---@class CAN.DetailItem
---@field Item string
local TDetailItem = {}
TDetailItem.__index = TDetailItem
TDetailItem.group = {}

local function TDetailItem_from_obj(obj)
    return setmetatable(obj, TDetailItem)
end

function TDetailItem.new(Item)
    return TDetailItem_from_obj({Item = Item})
end
---@param obj CAN.DetailItem
function TDetailItem:init_from_obj(obj)
    self.Item = obj.Item
end

function TDetailItem:remove_error_props(errs, obj)
    utils.remove_obj_error_property(obj, errs, TDetailItem.group)
end

TDetailItem.from_obj = TDetailItem_from_obj

TDetailItem.proto_property = {'Item'}

TDetailItem.default = {''}

TDetailItem.struct = {{name = 'Item', is_array = false, struct = nil}}

function TDetailItem:validate(prefix, errs, need_convert)
    prefix = prefix or ''

    validate.Optional(prefix .. 'Item', self.Item, 'string', false, errs, need_convert)

    TDetailItem:remove_error_props(errs, self)
    validate.CheckUnknowProperty(self, TDetailItem.proto_property, errs, need_convert)
    return self
end

function TDetailItem:unpack(_)
    return self.Item
end

CAN.DetailItem = TDetailItem

---@class CAN.PrintMetricsRsp
---@field Details CAN.DetailItem[]
local TPrintMetricsRsp = {}
TPrintMetricsRsp.__index = TPrintMetricsRsp
TPrintMetricsRsp.group = {}

local function TPrintMetricsRsp_from_obj(obj)
    obj.Details = utils.from_obj(CAN.DetailItem, obj.Details, true)
    return setmetatable(obj, TPrintMetricsRsp)
end

function TPrintMetricsRsp.new(Details)
    return TPrintMetricsRsp_from_obj({Details = Details})
end
---@param obj CAN.PrintMetricsRsp
function TPrintMetricsRsp:init_from_obj(obj)
    self.Details = obj.Details
end

function TPrintMetricsRsp:remove_error_props(errs, obj)
    utils.remove_obj_error_property(obj, errs, TPrintMetricsRsp.group)
end

TPrintMetricsRsp.from_obj = TPrintMetricsRsp_from_obj

TPrintMetricsRsp.proto_property = {'Details'}

TPrintMetricsRsp.default = {{}}

TPrintMetricsRsp.struct = {{name = 'Details', is_array = true, struct = CAN.DetailItem.struct}}

function TPrintMetricsRsp:validate(prefix, errs, need_convert)
    prefix = prefix or ''

    for _, v in pairs(self.Details) do
        CAN.DetailItem.new(v.Item):validate(prefix, errs, need_convert)
    end

    TPrintMetricsRsp:remove_error_props(errs, self)
    validate.CheckUnknowProperty(self, TPrintMetricsRsp.proto_property, errs, need_convert)
    return self
end

function TPrintMetricsRsp:unpack(raw)
    return utils.unpack(raw, self.Details, true)
end

CAN.PrintMetricsRsp = TPrintMetricsRsp

CAN.interface = mdb.register_interface('bmc.kepler.Debug.RemoteAccess.CAN', {}, {
    SendTestBoardcast = {
        'a{ss}y', '', TSendTestBoardcastReq, TSendTestBoardcastRsp, [=[Send a testing boardcast over canbus.]=]
    },
    PrintMetrics = {'a{ss}y', 'a(s)', TPrintMetricsReq, TPrintMetricsRsp, [=[Print the metrics of given canbus.]=]}
}, {})

return CAN
